﻿using Application_Core.Bestellung_Component.Data_Access_Layer;
using System.Linq;
using Utility.Persistence_Service;
using Utility.Persistence_Service.Implementations;

namespace Application_Core.Bestellung_Component.Data_Access_Layer.Implementations
{
    internal class AngebotRepositoryImpl : RepositoryImpl<Angebot>, AngebotRepository
    {
        public AngebotRepositoryImpl(UnitOfWork unitOfWork)
            : base(unitOfWork) { }

        /// <summary>
        /// Gibt das Angebot der gegebenen Angebotsnummer zurück.
        /// </summary>
        /// <param name="angebotsnummer">Angebotsnummer</param>
        /// <returns>Angebot | null</returns>
        public Angebot FindByNummer(int angebotsnummer)
        {
            return (from a in this.unitOfWork.Query<Angebot>() where a.Nummer == angebotsnummer select a)
                .FirstOrDefault() ?? null;
        }
    }
}
